/*Joseph A. Coll
RCV AP PreTreatment Check
7/23/2025*/

*Load data
use "G:\My Drive\Backup 08202022\Working Papers\RCV and AP\Data and Methods\RCV AP Data Cleaned.dta", clear
cd "G:\My Drive\Backup 08202022\Working Papers\RCV and AP\Tables and Figures RCV AP"

********************************************************************************	
********************************************************************************
********************************************************************************
**# Pre-Treatment: News Interest
********************************************************************************
********************************************************************************
********************************************************************************	
fre poli_int

********************************************************************************	
********************************************************************************
********************************************************************************
**#Main Analyses and Figures
********************************************************************************
********************************************************************************
********************************************************************************	

********************************************************************************
*Does Treatment Affect Affective Polarization
********************************************************************************
*FT
	*Affective polarization 
	reg ap_ft_change i.treatment##c.poli_int
	estimates store ap_ft_change_pret
	margins, dydx(treatment) at(poli_int=(1(1)4)) post 
	mplotoffset, ///
	ciopts(recast(rcap) msize(small)) ///
	scheme(plotplain) ///
	xscale(r(.75 4.25)) ///
	title("", size(medium)) ///
	ytitle("Affective Polarization {&Delta}") ///
	yline(0, lpattern(longdash) lcolor(black%60)) ///
	yscale(r(-.0325 .035)) ///
	ylabel(-.03(.01).03) ///
	legend(order(3 "RCV Compliment" 4 "RCV Compliment + Endorse") pos(6)) ///
	name(ap_ft_change_pret, replace) 
	graph export ap_ft_change_pret.png, replace
	
	*In group
	reg ap_ft_ip_change  i.treatment##c.poli_int
	estimates store ap_ft_ip_change_pret
	margins, dydx(treatment) at(poli_int=(1(1)4)) post 
	mplotoffset, ///
	ciopts(recast(rcap) msize(small)) ///
	scheme(plotplain) ///
	xscale(r(.75 4.25)) ///
	title("", size(medium)) ///
	ytitle("In-Group Affect {&Delta}") ///
	yline(0, lpattern(longdash) lcolor(black%60)) ///
	yscale(r(-.0325 .035)) ///
	ylabel(-.03(.01).03) ///
	legend(order(3 "RCV Compliment" 4 "RCV Compliment + Endorse") pos(6)) ///
	name(ap_ft_ip_change_pret, replace) 
	graph export ap_ft_ip_change_pret.png, replace	
	
	*Outgroup
	reg ap_ft_op_change  i.treatment##c.poli_int 
	estimates store ap_ft_op_change_pret
	margins, dydx(treatment) at(poli_int=(1(1)4)) post 
	mplotoffset, ///
	ciopts(recast(rcap) msize(small)) ///
	scheme(plotplain) ///
	xscale(r(.75 4.25)) ///
	title("", size(medium)) ///
	ytitle("Out-Group Affect {&Delta}") ///
	yline(0, lpattern(longdash) lcolor(black%60)) ///
	yscale(r(-.0325 .035)) ///
	ylabel(-.03(.01).03) ///
	legend(order(3 "RCV Compliment" 4 "RCV Compliment + Endorse") pos(6)) ///
	name(ap_ft_op_change_pret, replace) 
	graph export ap_ft_op_change_pret.png, replace	

	grc1leg ap_ft_change_pret ap_ft_ip_change_pret ap_ft_op_change_pret, ///
	title() ycommon  ///
	name(ft_combined_pret, replace)
	graph export ft_combined_pret.png, replace 

*Traits
	*Affective polarization
	reg ap_traits_change  i.treatment##c.poli_int 
	estimates store ap_traits_change_pret
	margins, dydx(treatment) at(poli_int=(1(1)4)) post 
	mplotoffset, ///
	ciopts(recast(rcap) msize(small)) ///
	scheme(plotplain) ///
	xscale(r(.75 4.25)) ///
	title("", size(medium)) ///
	ytitle("Affective Polarization {&Delta}") ///
	yline(0, lpattern(longdash) lcolor(black%60)) ///
	yscale(r(-.0325 .035)) ///
	ylabel(-.03(.01).03) ///
	legend(order(3 "RCV Compliment" 4 "RCV Compliment + Endorse") pos(6)) ///
	name(ap_traits_change_pret, replace) 
	graph export ap_traits_change_pret.png, replace
	
	*In group
	reg ap_traits_ip_change  i.treatment##c.poli_int 
	estimates store ap_traits_ip_change_pret
	margins, dydx(treatment) at(poli_int=(1(1)4)) post 
	mplotoffset, ///
	ciopts(recast(rcap) msize(small)) ///
	scheme(plotplain) ///
	xscale(r(.75 4.25)) ///
	title("", size(medium)) ///
	ytitle("In-Group Affect {&Delta}", size(*.9)) ///
	yline(0, lpattern(longdash) lcolor(black%60)) ///
	yscale(r(-.0325 .035)) ///
	ylabel(-.03(.01).03) ///
	legend(order(3 "RCV Compliment" 4 "RCV Compliment + Endorse") pos(6)) ///
	name(ap_traits_ip_change_pret, replace) 
	graph export ap_traits_ip_change_pret.png, replace
	
	*Out group
	reg ap_traits_op_change i.treatment##c.poli_int 
	estimates store ap_traits_op_change_pret
	margins, dydx(treatment) at(poli_int=(1(1)4)) post 
	mplotoffset, ///
	ciopts(recast(rcap) msize(small)) ///
	scheme(plotplain) ///
	xscale(r(.75 4.25)) ///
	title("", size(medium)) ///
	ytitle("Out-Group Affect {&Delta}") ///
	yline(0, lpattern(longdash) lcolor(black%60)) ///
	yscale(r(-.0325 .035)) ///
	ylabel(-.03(.01).03) ///
	legend(order(3 "RCV Compliment" 4 "RCV Compliment + Endorse") pos(6)) ///
	name(ap_traits_op_change_pret, replace) 
	graph export ap_traits_op_change_pret.png, replace

	grc1leg ap_traits_change_pret ap_traits_ip_change_pret ap_traits_op_change_pret, ///
	title() ycommon  ///
	name(t_combined_pret, replace)
	graph export t_combined_pret.png, replace 


*Feeling Thermometer table
	esttab ap_ft_change_pret ap_ft_ip_change_pret ap_ft_op_change_pret ///
	using apft_pret.tex, replace ///
	cells(b(star fmt(3)) se(fmt(3) par) ) starlevels( * 0.05 ** 0.01 *** 0.001) ///
	label ///
	stat(r2 N, fmt(2 0) label("R$^2$" "\textit{N}")) ///
	nodepvars nobase noomitted interaction(" x ") ///
	drop() ///
	style(tex) compress ///
	title("Electoral System, Candidate Communication, and Change in Partisan Affect (Feeling Thermometer)\label{tab:apftpretreat}") ///
	mlabel("Affective Polarization" "In-Group" "Out-Group") 
		
*Traits table
	esttab ap_traits_change_pret ap_traits_ip_change_pret ap_traits_op_change_pret ///
	using apt_pret.tex, replace ///
	cells(b(star fmt(3)) se(fmt(3) par) ) starlevels( * 0.05 ** 0.01 *** 0.001) ///
	label ///
	stat(r2 N, fmt(2 0) label("R$^2$" "\textit{N}")) ///
	nodepvars nobase noomitted interaction(" x ") ///
	drop() ///
	style(tex) compress ///
	title("Electoral System, Candidate Communication, and Change in Partisan Affect (Traits)\label{tab:aptpretreat}") ///
	mlabel("Affective Polarization" "In-Group" "Out-Group") 	
	
